package com.tanhua.server.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.common.mapper.BlackListMapper;
import com.tanhua.common.pojo.BlackList;
import com.tanhua.common.pojo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlackListService {
    @Autowired
    private BlackListMapper blackListMapper;

    public IPage<BlackList> queryBlackList(Long userId, Integer page, Integer pageSize){
        QueryWrapper<BlackList> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId).orderByAsc("created");
        Page<BlackList> page1 = new Page<>(page,pageSize);
        return blackListMapper.selectPage(page1, wrapper);
    }

    public boolean delBlackList(Long userId, Long blackUserId) {
        QueryWrapper<BlackList> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId).eq("black_user_id",blackUserId);
        return blackListMapper.delete(wrapper) > 0;
    }
}

